<?php

	header('Location: seeker/main.php');

	include('includes/smarty.php');
	include_once('config.php');
	
	$SEEKER = new Seeker();

	if(isset($_SESSION['seekerid']))
	{
		//	User is already logged in	
		//	Validate the session.
		
	}
	else
	{
		if(!empty($_POST))
		{
			//	The user tried to log in.
			
			$username = $_POST['un'];
			$password = $_POST['pw'];
			
			if($SEEKER->validate_login($username, $password))
			{
				//	The user should now be logged in.
				
				$_SESSION['seekerid'] 		= $row['admin_id'];
				$_SESSION['seekerfName'] 	= $row['fname'];
				$_SESSION['seekerlName'] 	= $row['lname'];
				
				//	Send the user to another page.
				
			}
			else
			{
				//	Login failed.
				//	Show login screen.
				
				$smarty->assign('title', 'Signup');
				$smarty->assign('path', $site);
				$smarty->assign('states', get_state_select());
				$smarty->assign('zipREX', 		$regex_zip);
				$smarty->assign('phoneREX', 	$regex_phone);
				$smarty->assign('emailREX', 	$regex_email);	
				$smarty->assign('leftCol', 'main/newsFeed.tpl');
				$smarty->assign('mainCol', 'main/seekerSignup.tpl');
				$smarty->assign('rightCol', 'main/signin.tpl');
				$smarty->assign('success', 'Your account has been successfully created.');
			}
			
		}		
	}
?>